#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int res=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){res=(res<<1)+(res<<3)+(c^48);c=getchar();}
	return res*f;
}
void write(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10+'0');
}
struct node
{
	int nxt,to;
}e[100005];
int head[100005],cnt_edge;
void add_edge(int u,int v)
{
	e[++cnt_edge].to=v;
	e[cnt_edge].nxt=head[u];
	head[u]=cnt_edge;
}
int n,m;
int tmp=1;
void dfs(int u,int fa,int dep,int s,int cnt)
{
	if(dep>m) return;
	if(s&(1<<u-1)) ++cnt;
	if(dep==m&&cnt!=1) tmp=0;
	for(int i=head[u];i;i=e[i].nxt)
	{
		int v=e[i].to;
		if(v==fa) continue;
		dfs(v,u,dep+1,s,cnt);
	}
}
int main()
{
	freopen("life.in","r",stdin);
	freopen("life.out","w",stdout);
	n=read(),m=read();
	for(int i=1;i<n;i++)
	{
		int u=read(),v=read();
		add_edge(u,v);add_edge(v,u);
	}
	int ans=0;
	for(int i=0;i<(1<<n);i++)
	{
		tmp=1;
		for(int j=1;j<=n;j++) dfs(j,0,1,i,0);
		ans+=tmp;
	}
	if(ans) puts("YES");
	else puts("NO");
	write(ans);
	return 0;
}
